/**
 * webpack配置文件
 */
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const path = require('path')

function resolve(dir) {
  return path.join(__dirname, dir)
}
module.exports = {
  mode: 'development',
  entry: {
    app: resolve('./src/index.js')
  },
  output: {
    path: resolve('./dist'),
    filename: '[name].js'
  },
  resolve: {
    extensions: ['.js'],
    alias: {
      '@': resolve('./src'),
      '@actions': resolve('./src/redux/actions')
    }
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        include: resolve('./src'),
        loader: 'babel-loader'
      }
    ]
  },
  devServer: {
    open: true,
    host: '127.0.0.1',
    port: 9999,
    hot: true,
    inline: true
  },
  plugins: [
    new HtmlWebpackPlugin({
      template: resolve('./index.html'),
      filename: 'index.html',
      hash: true,
      inject: true
    }),
    new webpack.HotModuleReplacementPlugin()
  ]
}